﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using Royaumes_Libres.Database;

namespace Royaumes_Libres.Database
{
    public class cArmy
    {
        protected int pPkArmy;
        protected int pNbArcher;
        protected int pNbWarrior;
        protected int pNbKnight;
        protected int pNbPriest;

        public int PkArmy { get { return this.pPkArmy; } }
        public int NbArcher { get { return this.pNbArcher; } }
        public int NbWarrior { get { return this.pNbWarrior; } }
        public int NbKnight { get { return this.pNbKnight; } }
        public int NbPriest { get { return this.pNbPriest; } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="PkKingdom"></param>
        ///<remarks>Francis Gagne</remarks>
        public cArmy(int PkKingdom)
        {
            SqlCommand cmd = cSQL.GetDbJeuCommand();

            try
            {
                cmd.Connection.Open();
                cmd.CommandText = "cde.spGetArmy";
                cmd.Parameters.Add(cSQL.Param("@PkKingdom", PkKingdom, SqlDbType.Int));
                SqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    this.pPkArmy = dr.GetInt32(0);
                    this.pNbWarrior = dr.GetInt32(1);
                    this.pNbArcher = dr.GetInt32(2);
                    this.pNbKnight = dr.GetInt32(3);
                    this.pNbPriest = dr.GetInt32(4);
                }

                cmd.Connection.Close();
            }
            catch (Exception ex)
            {
                cmd.Connection.Close();
                throw new Exception("cArmy(): " + ex.Message);
            }
        }

    }
}